package kr.co.project1.dao;

import java.util.List;

import kr.co.project1.base.BaseDao;
import kr.co.project1.base.PageDto;
import kr.co.project1.vo.BoardVO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

@Repository
public class BoardDao extends BaseDao{
	
	private static final Logger logger = LoggerFactory.getLogger(BoardDao.class);
	private static final String SQL_ID_PREFIX = "kr.co.project1.dao.BoardDao.";
	
	public PageDto<BoardVO> list(BoardVO boardVO) {
		logger.debug("======BoardService.list======");
		return selectPageList(SQL_ID_PREFIX + "list" ,boardVO, boardVO.getPage(), boardVO.getPageSize());
	}

	public int insertItem(BoardVO boardVO) {
		logger.debug("======BoardService.insertItem======");
		return getSqlSession().insert(SQL_ID_PREFIX + "insertItem" ,boardVO);
	}

	public BoardVO getItem(BoardVO boardVO) {
		logger.debug("======BoardService.getItem======");
		return getSqlSession().selectOne(SQL_ID_PREFIX + "getItem", boardVO);
	}

	public int modifyItem(BoardVO boardVO) {
		logger.debug("======BoardService.modifyItem======");
		return getSqlSession().update(SQL_ID_PREFIX + "modifyItem", boardVO);
	}

	public int deleteItem(BoardVO boardVO) {
		logger.debug("======BoardService.deleteItem======");
		return getSqlSession().delete(SQL_ID_PREFIX + "deleteItem", boardVO);
	}

	public List<BoardVO> replyList(BoardVO boardVO) {
		logger.debug("======BoardService.replyList======");
		return getSqlSession().selectList(SQL_ID_PREFIX + "replyList", boardVO);
	}

	public int replyInsert(BoardVO boardVO) {
		logger.debug("======BoardService.replyInsert======");
		return getSqlSession().insert(SQL_ID_PREFIX + "replyInsert", boardVO);
	}

	public int replyDelete(BoardVO boardVO) {
		logger.debug("======BoardService.replyDelete======");
		return getSqlSession().delete(SQL_ID_PREFIX + "replyDelete", boardVO);
	}


}
